home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / update~4.z / update~4 / lib_stdio_getw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  414 b   |  25 lines

  1. /*                g e t w
  2.  *
  3.  * Read a word from a stream. The function will return EOF on error.
  4.  * Because EOF is also a valid integer, it is better to check for
  5.  * errors using ferror.
  6.  *
  7.  * Patchlevel 1.0
  8.  *
  9.  * Edit History:
  10.  */
  11.  
  12. #include "stdiolib.h"
  13.  
  14. /*LINTLIBRARY*/
  15.  
  16. int getw(fp)
  17.  
  18. FILE *fp;                /* stream */
  19.  
  20. {
  21.   int w;                /* word read */
  22.  
  23.   return fread((void *) &w, (unsigned int)sizeof(int), 1, fp) == 1 ? w : EOF;
  24. }
  25.